package com.example.springbootminiodemo.config;

import io.minio.MinioClient;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@ConfigurationProperties(prefix = "minio")
@Data
public class MinioConfig {
  
  private String endpoint;
  private String accessKey;
  private String secretKey;
  
  @Bean(name = "minioClient")
  public MinioClient getMinioClient() {
    try {
      return MinioClient.builder().endpoint(endpoint).credentials(accessKey, secretKey).build();
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
}
